home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / C-D / CD ProgramReader.cpt / CD Programs Reader / card_3055.txt < prev    next >
Text File  |  1991-10-15  |  9KB  |  289 lines

  1. -- card: 3055 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 2785
  5. -- name: 
  6.  
  7.  
  8. -- part 2 (field)
  9. -- low flags: 05
  10. -- high flags: 0002
  11. -- rect: left=0 top=0 right=28 bottom=256
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 1
  15. -- font id: 3
  16. -- text size: 9
  17. -- style flags: 256
  18. -- line height: 12
  19. -- part name: CDRemotePrograms
  20. ----- HyperTalk script -----
  21. on mouseUp
  22.   put SystemFolder() & "CD Remote Programs" into me
  23. end mouseUp
  24.  
  25.  
  26. -- part 3 (field)
  27. -- low flags: 05
  28. -- high flags: 0002
  29. -- rect: left=0 top=30 right=256 bottom=256
  30. -- title width / last selected line: 0
  31. -- icon id / first selected line: 0 / 0
  32. -- text alignment: 0
  33. -- font id: 3
  34. -- text size: 9
  35. -- style flags: 256
  36. -- line height: 12
  37. -- part name: theText
  38. ----- HyperTalk script -----
  39. on mouseUp
  40.   put cd fld CDRemotePrograms into sourceFile
  41.   put short name of this stack into thisStack
  42.   put "My CD Collection" into newStack
  43.  
  44.   if there is not a file sourceFile then
  45.     answer "File:" && quote & sourceFile & quote && "was not found!" with "Get A Life"
  46.     exit mouseUp
  47.   end if
  48.  
  49.   put resList (sourceFile) into temp
  50.   repeat with i = 1 to number of lines in temp
  51.     if line i of temp contains "STR#" then
  52.       exit repeat
  53.     end if
  54.   end repeat
  55.  
  56.   if i >= number of lines in temp then
  57.     answer "No discs found in:" && quote & sourceFile & quote && "!" with "Get A Life"
  58.     exit mouseUp
  59.   end if
  60.  
  61.   create stack newStack in new window
  62.   if the result is not empty then
  63.     answer "Could not create" && quote & newStack & quote & ".  The file may already exist or the disk may be locked." with "Get A Life"
  64.     exit mouseUp
  65.   end if
  66.  
  67.   set script of stack newStack to script of me
  68.   send firstCard to stack newStack
  69.   doMenu "Close Stack"
  70.  
  71.   copyRes thisStack, newStack, "STR#", 8078 -- required for CD XCMDs.
  72.   copyRes thisStack, newStack, "XFCN", cdDiscTitle
  73.   copyRes thisStack, newStack, "XCMD", cdEject
  74.   copyRes thisStack, newStack, "XCMD", cdOpen
  75.   copyRes thisStack, newStack, "XCMD", cdPlayTrack
  76.   copyRes thisStack, newStack, "XCMD", cdSetDiscTitle
  77.   copyRes thisStack, newStack, "XFCN", cdStatus
  78.  
  79.   go to stack newStack in new window
  80.   put "cleanup" && quote & thisStack & quote & comma && quote & sourceFile & quote into theMessage
  81.   send theMessage to stack newStack
  82. end mouseUp
  83.  
  84. on cleanup useStack, sourceFile
  85.   start using stack useStack
  86.   put resList (sourceFile) into temp
  87.   repeat with i = 1 to number of lines in temp
  88.     if line i of temp contains "STR#" then
  89.       put item 3 of line i of temp into resourceID
  90.       copyRes sourceFile, short name of this stack, "STR#", resourceID
  91.       addDisc listDiscContents (resourceID)
  92.       killRes "STR#", resourceID
  93.     end if
  94.   end repeat
  95.   stop using stack useStack
  96.  
  97.   sort cards of this stack by bg fld discTitle
  98.   set script of me to restOfScript (script of me, "***")
  99.   doMenu "Compact Stack"
  100.   show all cards
  101. end cleanup
  102.  
  103. -- return delimited list of a CD's title and tracks
  104. function listDiscContents resourceID
  105. repeat with i = 1 to 999
  106.   put getStr (resourceID, i) into tempString
  107.   if tempString is empty then exit repeat
  108.   put tempString & return after theString
  109. end repeat
  110.  
  111. return theString
  112. end listDiscContents
  113.  
  114. on addDisc discInfo
  115.   if bg fld 1 is not empty then doMenu "New Card"
  116.   put line 1 of discInfo into bg fld discTitle
  117.   put line 2 to 999 of discInfo into bg fld trackTitles
  118. end addDisc
  119.  
  120. on firstCard trackScript
  121.   createBgField1
  122.   createBgField2
  123.   createBgButton1
  124.   createBgButton2
  125.  
  126.   set script of bg fld "discTitle"   to partOfScript(script of me, "~~~")
  127.   set script of bg fld "trackTitles" to partOfScript(script of me, "@@@")
  128.   set script of bg btn "Go Prev"     to partOfScript(script of me, "<<<")
  129.   set script of bg btn "Go Next"     to partOfScript(script of me, ">>>")
  130. end firstCard
  131.  
  132. on createBgField theTop, theLeft, theBottom, theRight
  133.   choose field tool
  134.   doMenu "Background"
  135.   drag from theLeft, theTop to theRight, theBottom with commandKey
  136.   doMenu "Background"
  137.   choose browse tool
  138. end createBgField
  139.  
  140. on createBgField1
  141.   createBgField 0, 0, 15, 256
  142.   set name of bg fld 1 to "discTitle"
  143.   set style of bg fld 1 to rectangle
  144.   set lockText of bg fld 1 to true
  145.   set textSize of bg fld 1 to 9
  146.   set textFont of bg fld 1 to Genvea
  147.   set textStyle of bg fld 1 to bold
  148.   set textAlign of bg fld 1 to center
  149. end createBgField1
  150.  
  151. on createBgField2
  152.   createBgField 17, 0, 235, 256
  153.   set name of bg fld 2 to "trackTitles"
  154.   set style of bg fld 2 to scrolling
  155.   set lockText of bg fld 2 to true
  156.   set textSize of bg fld 2 to 9
  157.   set textFont of bg fld 2 to Genvea
  158.   set textStyle of bg fld 2 to bold
  159. end createBgField2
  160.  
  161. on createBgButton theTop, theLeft, theBottom, theRight
  162.   choose button tool
  163.   doMenu "Background"
  164.   drag from theLeft, theTop to theRight, theBottom with commandKey
  165.   doMenu "Background"
  166.   choose browse tool
  167. end createBgButton
  168.  
  169. on createBgButton1
  170.   createBgButton 235, 0, 256, 30
  171.   set name of bg btn 1 to "Go Prev"
  172.   set icon of bg btn 1 to "Prev Arrow"
  173. end createBgButton1
  174.  
  175. on createBgButton2
  176.   createBgButton 235, 226, 256, 256
  177.   set name of bg btn 2 to "Go Next"
  178.   set icon of bg btn 2 to "Next Arrow"
  179. end createBgButton2
  180.  
  181. -- Return text of theScript located between two occurences of
  182. -- theToken & return.
  183. function partOfScript theScript, theToken
  184. put restOfScript (theScript, theToken) into theScript
  185. delete char offset (theToken & return, theScript) to 9999 of theScript
  186. delete last line of theScript
  187. return theScript
  188. end partOfScript
  189.  
  190. -- Return text of theScript minus all text before theToken & return.
  191. function restOfScript theScript, theToken
  192. delete char 1 to offset (theToken & return, theScript) of theScript
  193. delete first line of theScript
  194. return theScript
  195. end restOfScript
  196.  
  197. -- Permanent script of bg btn "Go Prev of the new stack is below.
  198. -- The partOfScript() routine will cut this script here ---> <<<
  199. on mouseUp
  200.   visual effect wipe right
  201.   do (short name of me)
  202. end mouseUp
  203. -- The partOfScript() routine will cut this script here ---> <<<
  204.  
  205. -- Permanent script of bg btn "Go Next" of the new stack is below.
  206. -- The partOfScript() routine will cut this script here ---> >>>
  207. on mouseUp
  208.   visual effect wipe left
  209.   do (short name of me)
  210. end mouseUp
  211. -- The partOfScript() routine will cut this script here ---> >>>
  212.  
  213. -- Permanent script of bg fld "discTitle" of the new stack is below.
  214. -- The partOfScript() routine will cut this script here ---> ~~~
  215. on mouseUp
  216.   edit script of this stack
  217. end mouseUp
  218. -- The partOfScript() routine will cut this script here ---> ~~~
  219.  
  220. -- Permanent script of bg fld "trackTitles" of the new stack is below.
  221. -- The partOfScript() routine will cut this script here ---> @@@
  222. on mouseUp
  223.   select the clickLine
  224.   if the selection is empty then
  225.     beep
  226.   else
  227.     playThis word 2 of the clickLine && bg fld discTitle
  228.     wait 1 second
  229.     select after last char of me
  230.   end if
  231. end mouseUp
  232. -- The partOfScript() routine will cut this script here ---> @@@
  233.  
  234. -- Permanent script of the new stack is below.
  235. -- The restOfScript() routine will cut this script here ---> ***
  236. -- Stack created by Claussoft International's "CD Programs Reader"
  237.  
  238. on playThis tuneInfo
  239.   if tuneInfo is empty then exit playThis
  240.  
  241.   put word 1 of tuneInfo into trackNumber
  242.   put word 2 to 99 of tuneInfo into discTitle
  243.  
  244.   if getCD (discTitle) then CDPlayTrack (trackNumber)
  245. end playThis
  246.  
  247. function getCD discTitle
  248. global xxxCDRefNum
  249.  
  250. CDOpen
  251.  
  252. put CDDiscTitle() into currTitle
  253. if currTitle = discTitle then return true -- Correct CD found
  254.  
  255. -- No CD found
  256. if xxxCDRefNum is empty or xxxCDRefNum = 0 then
  257.   answer "Please insert the Compact Disc:" & return & "         " & discTitle & "‚Ķ" with "Cancel" or "OK"
  258.   if it = "Cancel" then
  259.     return false
  260.   else
  261.     mountCD
  262.     return getCD(discTitle)
  263.   end if
  264. end if
  265.  
  266. -- Incorrect CD found
  267. if currTitle is empty then put "Untitled" into currTitle
  268. answer "The current Compact Disc is" && quote & currTitle & "." & quote & return & "It can be renamed to" && quote & discTitle & quote && "or ejected." with "Cancel" or "Rename CD" or "Eject CD"
  269. if it = "Cancel" then return false
  270. if it = "Rename CD" then
  271.   renameCD currTitle, discTitle
  272. else
  273.   CDEject
  274. end if
  275.  
  276. return getCD(discTitle)
  277. end getCD
  278.  
  279. on mountCD
  280.   repeat until CDStatus() >= 0
  281.     CDOpen
  282.   end repeat
  283. end mountCD
  284.  
  285. on renameCD oldTitle, newTitle
  286.   answer "Are you sure that you want to rename the CD:" && quote & oldTitle & quote && "to" && quote & newTitle & quote & "?" with "Cancel" or "Rename CD"
  287.   if it = "Rename CD" then CDSetDiscTitle(newTitle)
  288. end renameCD
  289.